package com.konne.nightmare.FastPublicOpinion.ui.information.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.blankj.utilcode.util.SizeUtils;
import com.konne.nightmare.FastPublicOpinion.R;
import com.konne.nightmare.FastPublicOpinion.base.BaseMvpFragment;
import com.konne.nightmare.FastPublicOpinion.base.BaseMvpPresenter;
import com.konne.nightmare.FastPublicOpinion.common.QJJzvdStd;
import com.konne.nightmare.FastPublicOpinion.ui.dialog.ImportTypePopup;
import com.konne.nightmare.FastPublicOpinion.utils.GlideUtils;
import com.konne.nightmare.FastPublicOpinion.utils.LoadProgressDialog;
import com.konne.nightmare.FastPublicOpinion.widget.PicShowView;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;

import cn.jzvd.Jzvd;
import cn.jzvd.JzvdStd;

/**
 * Create by ws.
 * on Data:2022/2/16  Time:下午 2:51.
 * description: 考试详情 .
 */
public class ExamDetailsFrag extends BaseMvpFragment {
    public static ExamDetailsFrag getInstance() {
        return new ExamDetailsFrag();
    }

    @Override
    protected BaseMvpPresenter createPresenter() {
        return new BaseMvpPresenter();
    }

    @Override
    public LoadProgressDialog getLoadDialog() {
        return null;
    }

    @Override
    public void cancelLoadDialog() {

    }

    @Override
    public int getLayout() {
        return R.layout.frag_exam_details;
    }

    @Override
    public void initView() {
        LinearLayout ll_content = (LinearLayout) findViewById(R.id.ll_data);
        ll_content.addView(getItemHasData());
        PicShowView showView= (PicShowView) findViewById(R.id.pic_show);
        showView.setVisibility(View.VISIBLE);
        showView.addView(getItemPicData("https://img2.baidu.com/it/u=2090606195,1473750087&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500"));
        JzvdStd jzvdStd= (JzvdStd) findViewById(R.id.jz_video);
        GlideUtils.loadImage("https://img0.baidu.com/it/u=2093655695,3099516187&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500",jzvdStd.posterImageView);
        jzvdStd.setUp("https://klxxcdn.oss-cn-hangzhou.aliyuncs.com/histudy/hrm/media/bg3.mp4","");
    }
    private View getItemPicData(String url) {
        ImageView pic=new ImageView(getContext());
        GlideUtils.loadImage(url,pic);
        pic.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        return pic;
    }
    private View getItemHasData() {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.item_has_data, null);
        ImageView pic = view.findViewById(R.id.iv_pic);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, SizeUtils.dp2px(80));
        view.setLayoutParams(params);
        view.findViewById(R.id.iv_remove).setVisibility(View.GONE);
        TextView stv_change = view.findViewById(R.id.stv_change);
        stv_change.setText("在线预览");
        return view;
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if(!isVisibleToUser){
            Jzvd.releaseAllVideos();
        }
    }

    @Override
    public void initData(Bundle savedInstanceState) {

    }
}
